﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fashion_API;

namespace A.Controller
{
    public class ProductPropertyController
    {
        public static List<ProductProperty> GetAllPropertyOfCategory(int categoryId)
        {
            using (DALDataContext d = new DALDataContext())
            {
                ProductCategory productCategory = ProductCategoryController.GetProductCategoryById(categoryId);
                List<ProductProperty> productProperties = d.ProductProperties.Where(i => i.CategoryId == categoryId).ToList();
                List<ProductProperty> productPropertiesParent =
                    d.ProductProperties.Where(i => i.CategoryId == (productCategory.ParentId==null?0:productCategory.ParentId)).ToList();
                return productProperties.Union(productPropertiesParent).ToList();
            }
        }
    }
}